In [1]:
from __future__ import division
from scipy.stats import norm
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams['lines.linewidth'] = 2
mpl.rcParams['lines.color'] = 'r'
mpl.rcParams['axes.titlesize'] = 32
mpl.rcParams['axes.labelsize'] = 24
mpl.rcParams['axes.labelsize'] = 24
mpl.rcParams['xtick.labelsize'] = 24
mpl.rcParams['ytick.labelsize'] = 24
%matplotlib inline
def make_normal_plot(zranges, xlabel="$z$", ylabel="$f_Z(z)$"):
plt.figure(figsize=(12, 8))
x = np.arange(-3, 3, 0.01)
plt.plot(x, norm.pdf(x, 0, 1), 'k-', linewidth=3)
for zrange in zranges:
z = np.arange(zrange[0], zrange[1], 0.01)
plt.fill_between(z, 0, norm.pdf(z, 0, 1), color="grey", alpha=0.3, edgecolor="k")
plt.xlabel(xlabel)
plt.ylabel(ylabel)
plt.xlim([min(x), max(x)])
return plt
In [2]:
make_normal_plot([[-2.25, 1.25]])
Out[2]:
In [2]: